import request from "./request";

export interface RegAns {
    code: number;
    msg: string;
}
export const userReg = (userAccount: string,userPwd: string,nickName: string) => {
    return request({
        url: '/user/reg',
        method: 'post',
        data: {
            userAccount,
            userPwd,
            nickName
        }
    })
}

export interface LoginAns {
    code: number;
    msg: string;
    token: string;
}
export const userLogin = (userAccount: string,userPwd: string) => {
    return request({
        url: '/user/login',
        method: 'post',
        data: {
            userAccount,
            userPwd
        }
    })
}

export interface GetUserInfoAns {
    code: number;
    msg: string;
    data: {
        nickName: string;
        avatar: string;
        userId: string;
    }
}
export const getUserInfo = () => {
    return request({
        url: '/user/getUser',
        method: 'get'
    })
}

export interface CgAns {
    code: number;
    msg: string;
}
export const cgName = (newName: string) => {
    return request({
        url: '/user/changeName',
        method: 'get',
        params: {
            newName
        }
    })
}
export const chPwd = (userPwd: string,newPwd: string) => {
    return request({
        url: '/user/changePwd',
        method: 'post',
        data: {
            userPwd,
            newPwd
        }
    })
}
export const chAva = (formdata: object) => {
    return request({
        url: '/user/changeAva',
        method: 'post',
        data: formdata
    })
}